package constant

import "net/http"

type ResponseCode int

const (
	SUCCESS  ResponseCode = 0   //成功
	CODE_400 ResponseCode = 400 //错误请求
	CODE_401 ResponseCode = 401 //未授权
	CODE_403 ResponseCode = 403 //禁止
	CODE_404 ResponseCode = 404 // 页面未找到
	CODE_405 ResponseCode = 405 // 方法禁用
	CODE_406 ResponseCode = 406 //不接受
	CODE_408 ResponseCode = 408 //请求超时
	CODE_409 ResponseCode = 409 //冲突
	CODE_410 ResponseCode = 410 //已删除
	CODE_411 ResponseCode = 411 //需要有效长度
	CODE_412 ResponseCode = 412 //未满足前提条件
	CODE_413 ResponseCode = 413 //请求实体过大
	CODE_415 ResponseCode = 415 //不支持的媒体类型
	CODE_416 ResponseCode = 416 //请求范围不符合要求
	CODE_417 ResponseCode = 417 //未满足期望值
	CODE_500 ResponseCode = 500 // 服务器错误
)

var codeTextMap = map[ResponseCode]string{
	SUCCESS:  "成功",
	CODE_404: "页面不存在",
	CODE_500: "服务器内部错误",
}

func GetCodeText(code ResponseCode) string {
	if value, ok := codeTextMap[code]; ok {
		return value
	}
	value := http.StatusText(int(code))
	if value != "" {
		return value
	}
	return "Unkown code text"
}
